home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Contributions / Interworks / Networking / INet-225 / include / rpc / auth.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-08  |  4.7 KB  |  166 lines

  1. /* @(#)auth.h    1.2 87/11/23 3.9 RPCSRC */
  2. /*
  3.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  4.  * unrestricted use provided that this legend is included on all tape
  5.  * media and as a part of the software program in whole or part.  Users
  6.  * may copy or modify Sun RPC without charge, but are not authorized
  7.  * to license or distribute it to anyone else except as part of a product or
  8.  * program developed by the user.
  9.  *
  10.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  11.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  12.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13.  *
  14.  * Sun RPC is provided with no support and without any obligation on the
  15.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  16.  * modification or enhancement.
  17.  *
  18.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20.  * OR ANY PART THEREOF.
  21.  *
  22.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  23.  * or profits or other special, indirect and consequential damages, even if
  24.  * Sun has been advised of the possibility of such damages.
  25.  *
  26.  * Sun Microsystems, Inc.
  27.  * 2550 Garcia Avenue
  28.  * Mountain View, California  94043
  29.  */
  30. /*    @(#)auth.h 1.16 87/10/01 SMI      */
  31.  
  32. #ifndef _RPC_AUTH_H
  33. #define _RPC_AUTH_H
  34.  
  35. /*
  36.  * auth.h, Authentication interface.
  37.  *
  38.  * Copyright (C) 1984, Sun Microsystems, Inc.
  39.  *
  40.  * The data structures are completely opaque to the client.  The client
  41.  * is required to pass a AUTH * to routines that create rpc
  42.  * "sessions".
  43.  */
  44.  
  45. #include <rpc/xdr.h>
  46.  
  47. #define MAX_AUTH_BYTES    400
  48. #define MAXNETNAMELEN    255    /* maximum length of network user's name */
  49.  
  50. /*
  51.  * Status returned from authentication check
  52.  */
  53. enum auth_stat {
  54.     AUTH_OK=0,
  55.     /*
  56.      * failed at remote end
  57.      */
  58.     AUTH_BADCRED=1,         /* bogus credentials (seal broken) */
  59.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  60.     AUTH_BADVERF=3,         /* bogus verifier (seal broken) */
  61.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  62.     AUTH_TOOWEAK=5,         /* rejected due to security reasons */
  63.     /*
  64.      * failed locally
  65.     */
  66.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  67.     AUTH_FAILED=7            /* some unknown reason */
  68. };
  69.  
  70. #if (mc68000 || sparc || vax || i386)
  71. typedef u_long u_int32; /* 32-bit unsigned integers */
  72. #endif
  73.  
  74. /*
  75.  * Authentication info.  Opaque to client.
  76.  */
  77. struct opaque_auth {
  78.     enum_t    oa_flavor;        /* flavor of auth */
  79.     caddr_t oa_base;        /* address of more auth stuff */
  80.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  81. };
  82.  
  83.  
  84. /*
  85.  * Auth handle, interface to client side authenticators.
  86.  */
  87. typedef struct AUTH {
  88.     struct    opaque_auth    ah_cred;
  89.     struct    opaque_auth    ah_verf;
  90.     struct auth_ops {
  91.         void    (*ah_nextverf)(struct AUTH *);
  92.         /* nextverf & serialize */
  93.         int    (*ah_marshal)(struct AUTH *, XDR *);
  94.         /* validate varifier */
  95.         int    (*ah_validate)(struct AUTH *, struct opaque_auth *);
  96.         /* refresh credentials */
  97.         int    (*ah_refresh)(struct AUTH *);
  98.         /* destroy this structure */
  99.         void    (*ah_destroy)(struct AUTH *);
  100.     } *ah_ops;
  101.     caddr_t ah_private;
  102. } AUTH;
  103.  
  104.  
  105. /*
  106.  * Authentication ops.
  107.  * The ops and the auth handle provide the interface to the authenticators.
  108.  *
  109.  * AUTH *auth;
  110.  * XDR    *xdrs;
  111.  * struct opaque_auth verf;
  112.  */
  113. #define AUTH_NEXTVERF(auth)        \
  114.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  115. #define auth_nextverf(auth)        \
  116.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  117.  
  118. #define AUTH_MARSHALL(auth, xdrs)    \
  119.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  120. #define auth_marshall(auth, xdrs)    \
  121.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  122.  
  123. #define AUTH_VALIDATE(auth, verfp)    \
  124.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  125. #define auth_validate(auth, verfp)    \
  126.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  127.  
  128. #define AUTH_REFRESH(auth)        \
  129.         ((*((auth)->ah_ops->ah_refresh))(auth))
  130. #define auth_refresh(auth)        \
  131.         ((*((auth)->ah_ops->ah_refresh))(auth))
  132.  
  133. #define AUTH_DESTROY(auth)        \
  134.         ((*((auth)->ah_ops->ah_destroy))(auth))
  135. #define auth_destroy(auth)        \
  136.         ((*((auth)->ah_ops->ah_destroy))(auth))
  137.  
  138.  
  139. extern struct opaque_auth _null_auth;
  140.  
  141.  
  142. /*
  143.  * These are the various implementations of client side authenticators.
  144.  */
  145.  
  146. /*
  147.  * Unix style authentication
  148.  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  149.  *    char *machname;
  150.  *    int uid;
  151.  *    int gid;
  152.  *    int len;
  153.  *    int *aup_gids;
  154.  */
  155. extern AUTH *authunix_create();
  156. extern AUTH *authunix_create_default(); /* takes no parameters */
  157. extern AUTH *authnone_create();     /* takes no parameters */
  158.  
  159. #define AUTH_NONE    0        /* no authentication */
  160. #define AUTH_NULL    0        /* backward compatibility */
  161. #define AUTH_UNIX    1        /* unix style (uid, gids) */
  162. #define AUTH_SHORT    2        /* short hand unix style */
  163. #define AUTH_DES    3        /* des style (encrypted timestamps) */
  164.  
  165. #endif
  166.